Skip to content

Adding the ability to extract additional bam-readcount fields into the #85

Merged
chrisamiller merged 3 commits into
griffithlab:masterfrom
chrisamiller:readcount_fields
Jun 30, 2026
Merged

Adding the ability to extract additional bam-readcount fields into the #85
chrisamiller merged 3 commits into
griffithlab:masterfrom
chrisamiller:readcount_fields

Conversation

@chrisamiller

@chrisamiller chrisamiller commented Jun 12, 2026

Copy link
Copy Markdown
Collaborator

I worked this up a while back, upon request of some folks doing heavy-duty variant filtering, and am just getting around to cleaning it up and pushing it. It adds code to extract one or more of the detailed bam-readcount fields about variants and their supporting reads and adds that info to the VCF.

@chrisamiller

Copy link
Copy Markdown
Collaborator Author

removed dockerfile - we'll make that a separate PR with github actions and such

Comment thread vatools/vcf_readcount_annotator.py Outdated
help='Append avg base quality of variant-supporting reads (FORMAT tag: VABQ).'
)
extra.add_argument(
'-E', '--avg-se-mapping-quality', action='store_true', default=False,

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure I'm a fan of the mix of upper and lower case single letter arguments but I suppose because of the number of arguments we are adding here, there isn't really a good way around it.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's totally fair - I generally dislike uppercase arguments too. Will add an update to address this

@susannasiebert susannasiebert left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A couple of small questions and requests but otherwise this looks good.

Comment thread vatools/vcf_readcount_annotator.py Outdated
Comment on lines +299 to +303
elif f.tag not in seen_extra_tags:
new_header.add_format_line(OrderedDict([
('ID', f.tag), ('Number', f.number), ('Type', f.vcf_type), ('Description', f.desc),
]))
seen_extra_tags.add(f.tag)

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not quite understanding why you need this logic with seen_extra_tags here.

Comment thread vatools/vcf_readcount_annotator.py Outdated
seen_extra_tags.add(f.tag)
return vcfpy.Writer.from_path(output_file, new_header)

def write_depth(entry, sample_name, field, value):

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we should consider renaming this method to better match what is being done here. e.g. add_format_value or something similar.

2) adds a more comprehensive test for these new arguments

3) removes the seen_extra_tags line, which was left over from a previous version. It already handles the case where -a and individual fields (e.g. -q) are provided
@chrisamiller

Copy link
Copy Markdown
Collaborator Author

Changes:

  1. renames some arguments to be all lowercase

  2. adds a more comprehensive test for these new arguments

  3. removes the seen_extra_tags line, which was left over from a previous version. It already handles the case where -a and individual fields (e.g. -q) are provided

  4. updates write_depth to be add_format_value, which is a much better function name

@susannasiebert susannasiebert left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

+1

@chrisamiller chrisamiller merged commit e1fcbc2 into griffithlab:master Jun 30, 2026
4 checks passed
@chrisamiller chrisamiller deleted the readcount_fields branch June 30, 2026 18:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants